﻿#ifndef TOUCHINJECTOR_H
#define TOUCHINJECTOR_H

#include <windows.h>
#include <QPoint>
#include <QList>
#include <QTouchEvent>
#include "TouchPoint.h"

// TouchInjector 负责将 Qt 的触摸事件注入回 Windows 系统
class TouchInjector
{
public:
    enum WorkMode {
        Touch,
        Mouse
    };

    explicit TouchInjector(int maxPoints = 10);
    virtual ~TouchInjector() = default;

    void setRect(const QRect& rect);
    void setOrientation(const Qt::ScreenOrientation& orientation);

    // 提交所有触摸点到系统
    void inject(const QList<TouchPoint>& points, WorkMode workMode=WorkMode::Touch);

protected:
    QPoint mapToScreen(const QPoint &pt) const;
    void handleTouch(const QList<TouchPoint>& points);
    void handleMouse(const QList<TouchPoint>& points);

private:
    QRect m_rect;
    Qt::ScreenOrientation m_orientation;
};

#endif // TOUCHINJECTOR_H
